#include <stdio.h>
#include <string.h>

char lc[30][150], in[10];

int s, n;

void draw(int shu, int y)
{
	int i, j, k;	
	i = 1;	
	if (shu==2 ||shu==3 ||shu==5 ||shu==6 ||shu==7 ||shu==8 ||shu==9 ||shu==0)
	for (k=1, j=y+1; k<=s; ++k,++j)		lc[i][j]='-';
	i += s+1;
	if (shu==2 ||shu==3 ||shu==4 ||shu==5 ||shu==6 ||shu==8 ||shu==9)
	for (k=1, j=y+1; k<=s; ++k,++j)		lc[i][j]='-';
	i += s+1;
	if (shu==2 ||shu==3 ||shu==5 ||shu==6 ||shu==8 ||shu==9 ||shu==0 )
	for (k=1, j=y+1; k<=s; ++k,++j)		lc[i][j]='-';

	j = y;
	i = 2;
	if (shu==4 ||shu==5 ||shu==6 ||shu==8 ||shu==9 ||shu==0)
	for (k=1; k<=s; ++k, ++i)		lc[i][j]='|';
	i = s+3;
	if (shu==2 ||shu==6 || shu==8||shu==0)
	for (k=1; k<=s; ++k, ++i)		lc[i][j]='|';
	
	j = y+s+1;
	i = 2;
	if (shu==1 ||shu==2 ||shu==3 ||shu==4 ||shu==7 ||shu==8 ||shu==9 ||shu==0)
	for (k=1; k<=s; ++k, ++i)		lc[i][j]='|';
	i = s+3;
	if (shu==1 ||shu==3 ||shu==4 ||shu==5 ||shu==6||shu==7 ||shu==8 ||shu==9 ||shu==0)
	for (k=1; k<=s; ++k, ++i)		lc[i][j]='|';
}

void output()
{
	int i, j, len;
	len = 2*s + 3;
	for (i=1; i<=len; ++i)
	{
		j=144;
		while (lc[i][j]==0) j--;
		while (--j>=0)		
			if (lc[i][j]==0) lc[i][j]=' ';		
	}
	for (i=1; i<=len; ++i)
		printf("%s\n", lc[i]);
	printf("\n");

}

int main()
{
	int i, len, x;
	while (1)
	{
		scanf("%d%d", &s ,&n);
		if (s==0 && n==0) break;
		memset(in, 0, sizeof(in));
		memset(lc, 0, sizeof(lc));

		sprintf(in, "%d", n);
		len = strlen(in);
		x = 0;
		for (i=0; i<len; i++)
		{
			draw(in[i]-'0',x);
			x += s+3;
		}
		output();
	}

	return 0;
}